package com.net.core.core.reuslt;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * author 张琳琅
 *
 * @param <T>
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Response<T> {

    //    @ApiModelProperty(value = "平台机构id",required = true)
//    @JacksonXmlProperty(localName = "resultCode")
    @ApiModelProperty(value = "状态码，200成功", required = true)
    private Integer code;

    //    @ApiModelProperty(value = "平台机构id",required = true)
//    @JacksonXmlProperty(localName = "responseMessage")
    @ApiModelProperty(value = "返回消息", required = true)
    private String message;

    //    @JSONField
//    @JacksonXmlProperty(localName = "item")
    private T data;

    //总耗时
    private long executeTime;

    /**
     * 类似黔江的那种 特殊需求使用
     *
     * @param data
     * @return
     */
    public Response setData(T data) {
        this.data = data;
        return this;
    }

    public Response<T> setCode(Integer code) {
        this.code = code;
        return this;
    }

    public Response<T> setMessage(String defaultSuccessMessage) {
        message = defaultSuccessMessage;
        return this;
    }

}
